import React, { Component } from 'react';
import {
	KeyboardAvoidingView, Platform,
	StyleSheet, Text, Modal,
	PixelRatio, View, Image, ScrollView
} from "react-native";
import { GLOBAL } from '../../../../config/global';
import { style } from '../../../../theme/style';
import { Common } from '../../../../component/common/Common.js';
import { API, API_GENERATE } from '../../../../config/api';
import HTTP from '../../../../utils/http';
import MethodUtil from '../../../../utils/MethodUtil';
import moment from 'moment';

import { BottomCpt } from '../../_components/BottomCpt';
import { BouncedCpt } from '../../_components/BouncedCpt';
import { BodyCpt } from '../../_components/BodyCpt';

const scale = GLOBAL.SCALE;

export class relevanceDetailPage extends Component {
	static navigationOptions = ({ navigation }) => {
		return {
			headerTitle: '计划关联',
			headerLeft: <Common type="headLeft" onPress={() => { navigation.goBack() }} />,
			headerRight: (<Image style={style.head.headRightEmpty} source={require('../../../../imgs/goBackEmpty.png')} />),
			headerStyle: {  // 头部整体样式 
				elevation: 0,
				backgroundColor: '#f7f7f7',
				borderBottomWidth: 0
			},
			headerTitleStyle: {
				flex: 1,
				textAlign: 'center'
			}
		}
	};
	constructor(props) {
		super(props);
		console.log('props-传参数', props.navigation.state.params);
		let { flagData, resultData } = props.navigation.state.params || {};
		let { orderType } = flagData || {};
		this.orderFlag = flagData || {};
		this.orderFeeList = resultData.orderFeeList || [];
		this.state = {
			tabIndex: orderType == 'P' ? 0 : 1,
			showRules: false,
			orderFees: 0, //毛利计算规则展示的杂费
			isVisible: false, //底部弹框
			isDetailsVisible: false //底部弹框
		}
		this.detailsData = {}; // 上一个页面传递参数
	}

	componentWillMount() {
		this._init();
	}

	_init = async () => {
		await this._showPriceFn();
		await this._getYxData();
		await this._getOrderMapping();

	}

	_showPriceFn = async () => {
		let { resultData } = this.props.navigation.state.params || {};
		let { orderId } = resultData || {};
		let { tCode } = this.orderFlag || {};

		let url = tCode == 'C' ? API.FIND_ORDER_C : (tCode == 'E' || tCode == 'QH' ? API.FIND_ORDER_E : API.FIND_ORDER)
		let sendData = await HTTP.POST(API_GENERATE(url), { orderId });
		let responseData = await HTTP.POST(API_GENERATE(API.NEW_ORDER_SHOW_PRICE), sendData);
		this.showPrice = responseData;
		this._detailsSend(responseData)
	}


	//查询意向
	_getYxData = async () => {
		if (orderType == 'S') return;
		let { resultData, flagData } = this.props.navigation.state.params || {};
		let { orderId } = resultData || {};
		let { orderType } = flagData || {};
		let response = await HTTP.POST(API_GENERATE(API.GET_ORDER_RPTEXT), { orderId });
		console.log('response-意向', response);
		if (response) {
			this._releaseData({ data: response, type: 0 });
			this.setState({
				orderRptInfo: response
			})
		}
	}

	// 意向计算
	_releaseData(params) {
		let { flagData } = this.props.navigation.state.params || {};
		let { orderType } = flagData || {};
		let { data } = params;
		let totalPlanGrossProfit = 0;
		let totalPlanQuan = 0;
		let planGrossProfit = 0;
		data && data.map(list => {
			list.rptExtList = list.rptExtList || [];
			list.rptExtList.length && list.rptExtList.map((rpt, j) => {
				let unprice = orderType === 'P' ? (rpt.planSellPrice - list.price) : (list.price - rpt.planSellPrice);
				totalPlanQuan = totalPlanQuan + rpt.planSellQuantity;
				rpt.planGrossProfit = parseFloat(rpt.planSellQuantity) * parseFloat(unprice);
				planGrossProfit = planGrossProfit + rpt.planGrossProfit;
			})
			list.planSellQuantity = totalPlanQuan;
			list.planGrossProfit = planGrossProfit;
			totalPlanGrossProfit = totalPlanGrossProfit + list.planGrossProfit;
		})

		this.setState({
			orderRptInfo: data,
			totalPlanGrossProfit
		})

		// return { data, totalPlanGrossProfit };
	}

	// 计算详情数据 参数整合
	_detailsSend = (sendData) => {
		let { orderPriceInfo, orderPriceItemList } = sendData || {};
		let { fundCreditFee, fundVoucherFee, averageOtherCost, logisticsFee } = orderPriceInfo || {};
		this.detailsData.yunfei = logisticsFee;

		this.detailsData.averageOtherCost = averageOtherCost || null; //杂费
		this.detailsData.fundCreditFee = fundCreditFee || null; //资金授信
		this.detailsData.fundVoucherFee = fundVoucherFee || null; //资金票据
		this.detailsData.orderPriceItemList = orderPriceItemList || [];
	}

	_getOrderMapping = async () => {
		let orderFees = 0;
		let totalMappingProfit = 0;
		let orderTotalMapping = 0;
		let { resultData, flagData } = this.props.navigation.state.params || {};
		let { orderId, companyName, orderItemList } = resultData || {};
		let { orderType, logisticsPrice, tCode } = flagData || {};
		let response = await HTTP.POST(API_GENERATE(API.USED_MAPPING_LIST), { orderId, orderType, isLast: 0 });
		console.log('response-计划关联', resultData);
		if (!response || !response.length) {
			response = [];
			orderItemList && orderItemList.length && orderItemList.map((item, index) => {
				response[index] = {};
				response[index]['groupName'] = item.goodsName;
				response[index]['availableQuantity'] = item.quantity;
				response[index]['orderInfo'] = {};
				response[index]['orderInfo']['goodsId'] = item.goodsId;
				response[index]['orderInfo']['batchNo'] = item.batchNo;
				response[index]['orderInfo']['orderId'] = item.orderId;
				response[index]['orderInfo']['orderType'] = item.orderType;
				response[index]['orderInfo']['companyName'] = companyName;
			})
		} else {
			//计算合计利润
			response.map((item, index) => {
				let quantity = 0;
				let mappingFees = 0;
				let expectALl = 0; //总毛利
				let expect = 0; //预计毛利

				item.pocketPrice = this.detailsData.orderPriceItemList[index].pocketPrice || 0; //落袋价
				let average = 0;
				if (tCode == 'C') {
					average = this._averageC() || 0; // 均价
				} else {
					average = this._average(item.stockMappingList) || 0; // 均价
				}

				if (tCode == 'C') {
					expect = average;
				} else {
					if (orderType == 'P') {
						expect = MethodUtil.countObj.subtract(average, item.pocketPrice);// //计算规则 -> 预计毛利     (采)预计毛利 =( 均价(关联销售) - 落代价)
					} else {
						expect = MethodUtil.countObj.subtract(item.pocketPrice, average);// //计算规则 -> 预计毛利 
					}
				}

				item.stockMappingList && item.stockMappingList.map(async (mapping, i) => {
					const { lockedTO, orderInfo } = mapping;
					// 单商品总关联数量
					quantity = quantity + lockedTO.lockedQuantity;
					item.lockedQuantity = quantity;
					// 单关联毛利
					mapping.expectSingle = MethodUtil.countObj.multiply(expect, lockedTO.lockedQuantity, 2);
					// 单商品总毛利
					expectALl = MethodUtil.countObj.add(expectALl, mapping.expectSingle, 2)
					// 获取关联订单的杂费,XC-API.ZXY_ORDER_INFO
					let response = await HTTP[orderInfo.ywType == 'ZXY' ? 'GET' : 'POST'](API_GENERATE(orderInfo.ywType == 'ZXY' ? API.ZXY_ORDER_INFO : API.FIND_ORDER), { orderId: orderInfo.orderId });
					let orderFees = 0;
					if (response) {
						let orderFeeList = orderInfo.ywType == 'ZXY' ? response.orderFeeList : response.zxyOrderFeeVOs;
						orderFeeList && orderFeeList.length && orderFeeList.map((item, index) => {
							let itemfee = orderInfo.ywType == 'ZXY' ? parseFloat(item.feeAmt || 0) * parseFloat(orderInfo.pbocPrice || 0) : parseFloat(item.feeAmt || 0);
							orderFees = orderFees + (itemfee || 0);
						})
					}
					mappingFees = mappingFees + orderFees;
				})

				orderItemList && orderItemList.length && orderItemList.map((proItem, index) => {
					if (proItem.goodsId === item.orderInfo.goodsId) {
						//单商品总（待关）量
						item.totalQuantity = proItem.quantity || 0;
						// 单商品总待关联量=单商品总量-单商品已关联量
						item.availableQuantity = (proItem.quantity || 0) - (item.lockedQuantity || 0);
					}
				})
				// 订单总毛利
				totalMappingProfit = totalMappingProfit + (expectALl || 0);
				// 毛利计算规则展示该订单总关联量
				orderTotalMapping = orderTotalMapping + (item.lockedQuantity || 0);
				// 均价
				item.average = average;
				// 预计毛利
				item.expect = expect;
				// 总毛利
				item.expectALl = expectALl;
				// 单商品杂费
				item.mappingFees = mappingFees;
			})
		}

		//计算主体订单杂费
		this.orderFeeList.map((item, index) => {
			orderFees = orderFees + parseFloat(item.feeAmt)
		})
		console.log('response-完结了', response)
		this.setState({
			orderMappingInfo: response,
			totalMappingProfit,
			orderTotalMapping,
			orderFees
		})
	}

	_tabFn = (num) => {
		this.setState({
			tabIndex: num
		})
	}

	//意向
	_intentionView = () => {
		let { flagData } = this.props.navigation.state.params || {};
		let { orderType } = flagData || {};
		const { orderRptInfo } = this.state;
		return (
			<View>
				{
					orderRptInfo && orderRptInfo.length ?
						orderRptInfo.map((rptInfo, index) => {
							const { goodsId, goodsName, planSellQuantity, totalQuantity, companyName, companyAddress, uomName, planSellPrice, price,
								planRecvTypeName, planSellBeginDate, planSellEndDate, rptExtList, extId } = rptInfo;
							return (
								<View key={index} style={styles.itemBox}>
									<View style={styles.head}>
										<Text style={styles.headTitle}>{goodsName ? (goodsName.length > 20 ? goodsName.substr(0, 20) + "..." : goodsName) : ""}</Text>
										<Text style={styles.headInfo}>已关联: {(planSellQuantity || 0).toFixed(3) || 0} 吨 | 待关联: {parseFloat(totalQuantity - planSellQuantity).toFixed(3) || 0} 吨</Text>
									</View>
									{
										rptExtList && rptExtList.length ?
											rptExtList.map((item, i) => {
												const { planSellQuantity, companyName, companyAddress, planSellPrice, price,
													planRecvTypeName, planSellBeginDate, planSellEndDate, planGrossProfit } = item || {};
												return (
													<View key={i} style={[styles.contian, styles.xian]}>
														<Text style={styles.ctTitle}>{companyName || ''}</Text>
														<View>
															<View style={styles.ctInputBox}>
																<View style={[{ flexDirection: 'row' },]}>
																	<Text>{item.planSellQuantity || 0}</Text>
																	<Text style={styles.ctInputText}>{item.uomName || '吨'}</Text>
																</View>
																<Text style={styles.money}>{item.planSellPrice || 0}</Text>
																<Text style={styles.ctInputText}>元/{item.uomName || '吨'}</Text>
																<Text style={[styles.ctInputText, styles.money]} >毛利：<Text style={styles.ctInputTextRed}>¥ {item.planGrossProfit.toFixed(2) || 0} 元</Text></Text>
															</View>
														</View>
														<View style={styles.ctItem}>
															<Text style={styles.ctItemLable}>付款类型</Text>
															<Text style={styles.ctItemText}>{planRecvTypeName || ''}</Text>
														</View>
														<View style={styles.ctItem}>
															<Text style={styles.ctItemLable}>销售时间</Text>
															<Text style={styles.ctItemText}>{planSellBeginDate && moment(planSellBeginDate).format("YYYY/MM/DD") || ''}-{planSellEndDate && moment(planSellEndDate).format("YYYY/MM/DD") || ''}</Text>
														</View>
														<View style={styles.ctItem}>
															<Text style={styles.ctItemLable}>目的地</Text>
															<Text style={styles.ctItemText}>{companyAddress || ''}</Text>
														</View>
													</View>)
											}) : <View style={styles.emptyView}>
												<Text style={style.emptyText}>暂无关联任何{orderType == 'P' ? '销售' : '采购'}意向</Text>
											</View>
									}
								</View>)
						}) : null
				}
			</View>
		)
	}


	//均价
	_average = (sendData) => {  // 均价 = (关联总价格 / 关联总数量 )   关联总价格 = 多个关联累加(关联价格*关联数量)
		let tolPrice = 0;
		let tolQuantity = 0;
		sendData && sendData.forEach(item => {
			const { lockedTO, orderInfo } = item;
			tolQuantity = tolQuantity + lockedTO.lockedQuantity; //多个已关联总量
			tolPrice = tolPrice + orderInfo.price * lockedTO.lockedQuantity;  //多个已关联总价
		})
		if (tolQuantity) {
			return MethodUtil.countObj.divide(tolPrice, tolQuantity, 2) || 0;
		} else {
			return 0
		}
	}

	//均价(闭口)
	_averageC = () => {  // 均价 = (关联总价格 / 关联总数量 )   关联总价格 = 多个关联累加(关联价格*关联数量)
		try {
			let { orderPriceItemList } = this.showPrice || {};

			let salePrice = orderPriceItemList[0].price || 0;
			let buyPrice = orderPriceItemList[0].purchaseOrderItem.price || 0;
			let fundVoucherFee = MethodUtil.countObj.add(orderPriceItemList[0].purchaseOrderItem.fundVoucherFee || 0, orderPriceItemList[0].fundVoucherFee || 0) || 0;
			let fundCreditFee = MethodUtil.countObj.add(orderPriceItemList[0].purchaseOrderItem.fundCreditFee || 0, orderPriceItemList[0].fundCreditFee || 0) || 0;

			let yufeiAll = MethodUtil.countObj.add(fundVoucherFee, fundCreditFee) || 0;

			let buyAll = MethodUtil.countObj.add(yufeiAll, buyPrice) || 0;
			console.log('haha', MethodUtil.countObj.subtract(salePrice, buyAll))
			return MethodUtil.countObj.subtract(salePrice, buyAll)

		} catch (err) {
			console.error('闭口计算出错', err)
		}
		return 0
	}

	//采购成交
	_sellView = () => {
		const { orderMappingInfo } = this.state;
		let { flagData, resultData } = this.props.navigation.state.params || {};
		let { orderType, tCode, res } = flagData || {};
		let { orderItemList } = resultData || {};
		return (
			<View>
				{
					orderMappingInfo && orderMappingInfo.length ?
						orderMappingInfo.map((orderMapping, index) => {
							let { groupName, orderInfo, stockMappingList, lockedQuantity, availableQuantity, totalQuantity, average, expectALl, expect } = orderMapping;
							let { orderPriceItemList } = this.detailsData || {};
							let { price, pocketPrice } = orderPriceItemList[index] || {};
							return (
								<View key={index} style={styles.itemBox}>
									<View style={[styles.head, styles.xian]}>
										<View style={[styles.rowbt, styles.ptop]}>
											<Text style={styles.bold}>{groupName ? (groupName.length > 20 ? groupName.substr(0, 20) + "..." : groupName) : ""}</Text>
											<Text style={styles.bold}>¥ {average || '-'}元/吨</Text>
										</View>
										<View style={styles.rowbt}>
											<View style={styles.rowItem}>
												<Text style={styles.norl}>已关联</Text>
												<Text style={styles.bold} >{parseFloat(lockedQuantity || 0).toFixed(3) || 0} 吨</Text>
											</View>
											<View style={styles.rowItem}>
												<Text style={styles.norl}>待关联</Text>
												<Text style={styles.bold} >{parseFloat(availableQuantity).toFixed(3) || 0} 吨</Text>
											</View>
											<View style={styles.rowItem}>
												<View style={styles.rowbt}>
													<Text style={styles.norl}>总毛利</Text>
													<Text style={[styles.norl, styles.themeColor]} onPress={() => {
														if (tCode == 'C') {
															this._hideDetials(true)
														} else {
															this._showDetialsTwo(true, { ...this.detailsData, average, expect, lockedQuantity, groupName, expectALl, totalQuantity, price, pocketPrice, index })
														}

													}} >[计算明细]</Text>
												</View>
												<View style={styles.rowbt}>
													<Text style={[styles.bold, styles.colorRed]} >{(expectALl || 0).toFixed(2) || 0}元</Text>
												</View>
											</View>
										</View>
									</View>
									{
										stockMappingList && stockMappingList.length ?
											stockMappingList.map((item, i) => {
												const { lockedTO, orderInfo } = item;
												const { lockedQuantity, portName } = lockedTO || {};
												const { companyName, orderId, price, currency, pbocPrice, dutyRate, vatRate } = orderInfo || {};
												return (
													<View key={i} style={[styles.contian, styles.xian]}
													>
														<Text style={styles.ctTitle}>{companyName} | {orderId}</Text>

														<View>
															<View style={styles.ctInputBox}>
																<View style={{ flexDirection: 'row', alignItems: 'center' }}>
																	<Text style={{ fontSize: 11 * scale }}>{lockedQuantity}</Text>
																	<Text style={{ fontSize: 11 * scale }} >吨</Text>
																</View>
																<Text style={[{ fontSize: 11 * scale }, styles.money]} >¥ {price || 0}元/吨</Text>
																<Text style={[{ fontSize: 11 * scale }, styles.money]} >毛利：<Text style={styles.ctInputTextRed}>¥ {(item.expectSingle || 0).toFixed(2) || 0} 元</Text></Text>
															</View>
															{portName ? <Text style={{ fontSize: 11 * scale, paddingBottom: 8 * scale }}>报关港口：{portName}</Text> : null}
															{currency !== 'RMB' ? <Text style={{ fontSize: 11 * scale, opacity: .7 }}>美金汇率：{pbocPrice} | 增值税税率：{vatRate} | 关税税率：{dutyRate}</Text> : null}
														</View>
													</View>
												)
											}) : <View style={styles.emptyView}>
												<Text style={styles.emptyText}>暂无关联任何{orderType == 'P' ? '销售' : '采购'}计划 </Text>
											</View>
									}
								</View>
							)
						}) : null
				}
			</View>
		)
	}

	//隐藏/关闭详情弹框
	_hideDetials = (boolean) => {
		this.setState({
			isVisible: boolean
		})
	}
	//隐藏/关闭 计算明细 弹框
	_hideDetialsTwo = (boolean) => {
		this.setState({
			isDetailsVisible: boolean
		})
	}

	//隐藏/关闭 计算明细 弹框
	_showDetialsTwo = (boolean, detaisData) => {
		this.detailsDataAll = detaisData;
		console.log('detaisData', detaisData)
		this.setState({
			isDetailsVisible: boolean
		})
	}

	//计算底部弹框 总毛利
	_totalGrossProfitAmt = () => {
		const { orderMappingInfo } = this.state;
		let results = 0;
		orderMappingInfo && orderMappingInfo.forEach(item => {
			results = MethodUtil.countObj.add(results, item.expectALl);
		})
		console.log('results', results)
		return results;
	}

	render() {
		let { tabIndex, isVisible, isDetailsVisible } = this.state;
		let { flagData } = this.props.navigation.state.params || {};
		let { orderType } = flagData || {};
		return (
			<View style={styles.container}>
				<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : null} keyboardVerticalOffset={20} >
					{
						orderType == 'P' ? (<View style={styles.tabBox}>
							<Text onPress={() => { this._tabFn(0) }} style={[styles.itemTab, tabIndex == 0 ? styles.itemTabActive : null]}>意向客户</Text>
							<Text onPress={() => { this._tabFn(1) }} style={[styles.itemTab, tabIndex == 1 ? styles.itemTabActive : null]}>{orderType == 'P' ? '销售' : '采购'}成交</Text>
						</View>) : null
					}
					<View style={styles.subtitle}>
						{/* {tabIndex ? <Text style={styles.rules} onPress={() => {
							this.setState({
								showRules: true
							})
						}}>【查看毛利计算规则】</Text> : null} */}
					</View>
					<ScrollView style={{ marginBottom: 80 * scale }}>
						{tabIndex ? this._sellView() : this._intentionView()}
					</ScrollView>
				</KeyboardAvoidingView>
				{/* 底部弹框 */}
				<BouncedCpt isVisible={isVisible} data={{
					closeFn: () => { this._hideDetials(false) },
					renderBody: <BodyCpt data={{ orderFlag: this.orderFlag, priceData: this.showPrice }} closeFn={() => { this._hideDetials(false) }} />
				}} />
				<BottomCpt data={{
					isSssociated: true,
					totalGrossProfitAmtActive: this._totalGrossProfitAmt(), // 底部总毛利
					priceData: {
						data: this.showPrice,
						isProfit: true, // 是否有毛利的标示
						callback: () => { this._hideDetials(true) }
					}
				}} />

				{/* 计算明细详情 */}
				<BouncedCpt isVisible={isDetailsVisible} data={{
					closeFn: () => { this._hideDetials(false) },
					renderBody: <BodyCpt title={'毛利计算明细'} data={{ detailsDataAll: this.detailsDataAll, relation: true, orderFlag: this.orderFlag, priceData: this.showPrice }} closeFn={() => { this._hideDetialsTwo(false) }} />
				}} />



			</View>
		)
	}
}
const styles = StyleSheet.create({
	container: {
		flex: 1,
		backgroundColor: '#f7f7f7',
		paddingLeft: 12 * scale,
		paddingRight: 12 * scale
	},
	tabBox: {
		width: '100%',
		height: 34 * scale,
		borderWidth: 1 / PixelRatio.get(),
		borderColor: style.color.themeColor,
		flexDirection: 'row',
		alignItems: 'center',
	},
	xian: {
		borderBottomWidth: 1 / PixelRatio.get(),
		borderStyle: 'solid',
		borderBottomColor: '#E3E7F0',
	},
	itemTab: {
		width: '50%',
		height: 33 * scale,
		lineHeight: 33 * scale,
		textAlign: 'center',
		color: style.color.themeColor,
		backgroundColor: style.color.white,
	},
	itemTabActive: {
		backgroundColor: style.color.themeColor,
		color: style.color.white
	},
	subtitle: {
		display: 'flex',
		flexDirection: 'row',
		alignItems: 'center'
	},
	rules: {
		textAlign: 'left',
		fontSize: 13 * scale,
		color: style.color.themeColor,
		paddingTop: 15 * scale,
		marginBottom: 5 * scale
	},
	total: {
		flex: 1,
		textAlign: 'right',
		fontSize: 13 * scale,
		paddingTop: 15 * scale,
		marginBottom: 5 * scale
	},
	colorActive: {
		color: style.color.lightRed
	},
	itemBox: {
		backgroundColor: style.color.white,
		width: '100%',
		borderRadius: 4 * scale,
		paddingTop: 10 * scale,
		paddingBottom: 10 * scale,
		paddingLeft: 12 * scale,
		paddingRight: 12 * scale,
		marginBottom: 20 * scale
	},
	head: {
		borderBottomWidth: 1 / PixelRatio.get(),
		borderStyle: 'solid',
		borderBottomColor: style.color.gray,
		position: 'relative',
		paddingBottom: 10 * scale
	},
	headBtn: {
		fontSize: 13 * scale,
		color: style.color.themeColor,
		//position: 'absolute',
		right: 0,
		top: 0,
		//marginBottom: 10 * scale
	},
	headTitle: {
		fontWeight: 'bold',
		color: style.color.black,
		marginBottom: 10 * scale
	},
	headInfo: {
		fontSize: 13 * scale,
	},
	contian: {
		paddingTop: 10 * scale,
		paddingBottom: 10 * scale,
		position: 'relative'
	},
	ctTitle: {
		fontWeight: 'bold',
		lineHeight: 26 * scale,
	},
	ctItem: {
		flexDirection: 'row',
		alignItems: 'center',
	},
	ctItemLable: {
		color: '#999',
		width: 65 * scale,
		fontSize: 13 * scale,
	},
	ctItemText: {
		fontSize: 13 * scale,
		lineHeight: 26 * scale,
	},
	noData: {
		textAlign: 'center',
		paddingTop: 25 * scale,
		paddingBottom: 25 * scale
	},
	removeText: {
		lineHeight: 26 * scale,
		position: 'absolute',
		right: -10 * scale,
		top: 8 * scale,
		zIndex: 9,
		color: style.color.themeColor,
		fontSize: 13 * scale,
		paddingLeft: 10 * scale,
		paddingRight: 10 * scale,
	},
	btnBox: {
		flexDirection: 'row',
		alignItems: 'center',
		justifyContent: 'center',
		height: 50 * scale,
		backgroundColor: 'rgba(0,0,0,0)',
		position: 'absolute',
		bottom: 10 * scale,
		left: 0,
		width: '100%',
	},
	emptyView: {
		width: '100%',
		borderTopWidth: 1 / PixelRatio.get(),
		borderStyle: 'solid',
		borderTopColor: style.color.gray,
		paddingTop: 25 * scale,
		paddingBottom: 20 * scale,
		alignItems: 'center'
	},
	modalBox: {
		flex: 1,
		justifyContent: 'center',
		alignItems: 'center',
		backgroundColor: 'rgba(0,0,0,0.5)',
	},
	rulesCont: {
		height: '80%',
		width: '90%',
		backgroundColor: '#fff',
		shadowColor: '#D2D2D2',
		// shadowOffset: { width: 6 * scale, height: 6 * scale },
		shadowRadius: 2,
		shadowOpacity: 0.5,
		borderRadius: 8 * scale
	},
	rulesTitle: {
		flexDirection: 'row',
		alignItems: 'center',
		justifyContent: 'space-between',
	},
	rulesClose: {
		fontSize: 26 * scale,
		color: '#000',
		textAlign: 'right',
		marginRight: 12 * scale,
	},
	rulesTitleText: {
		fontSize: 16 * scale,
		color: '#000',
		textAlign: 'left',
		marginLeft: 12 * scale,
	},
	rulesTotalCard: {
		flexDirection: 'row',
		alignItems: 'center',
		justifyContent: 'center',
		backgroundColor: '#f4f7fe',
		borderRadius: 8 * scale,
		margin: 12 * scale,
		padding: 12 * scale,
		marginBottom: 0
	},
	rulesTotalCardItem: {
		flex: 1,
	},
	rulesTotalCardLabel: {
		marginBottom: 10 * scale
	},
	rulesTotalProfit: {
		color: style.color.lightRed
	},
	rulesItemView: {
		margin: 12 * scale,
		borderBottomWidth: 1 / PixelRatio.get(),
		borderStyle: 'solid',
		borderBottomColor: style.color.gray,
	},
	rulesItem: {
		flexDirection: "row",
		alignItems: 'center',
		// justifyContent: 'center',
		marginBottom: 10 * scale,
	},
	rulesItemText: {
		flex: 1,
		fontSize: 13 * scale
	},
	rulesItemProfit: {
		color: style.color.lightRed,
		textAlign: 'right',
		marginBottom: 14 * scale,
		marginRight: 10 * scale,
		fontSize: 13 * scale
	},
	rulesItemHead: {
		marginBottom: 12 * scale,
		fontSize: 13 * scale
	},
	rulesItemTitleLeft: {
		marginTop: 8 * scale,
		marginBottom: 4 * scale,
		flex: 1,
		fontWeight: 'bold',
		fontSize: 13 * scale
	},
	rulesItemTitleRight: {
		marginTop: 8 * scale,
		marginBottom: 4 * scale,
		flex: 1,
		fontWeight: 'bold',
		fontSize: 13 * scale
	},
	ctInputBox: {
		flex: 1,
		flexDirection: 'row',
		alignItems: 'center',
		paddingTop: 8 * scale,
		paddingBottom: 8 * scale
	},
	ctInput: {
		fontSize: 13 * scale,
		borderWidth: 1 / PixelRatio.get(),
		borderStyle: 'solid',
		borderColor: style.color.gray,
		height: 28 * scale,
		width: 100 * scale,
		marginRight: 5 * scale,
		paddingVertical: 0,
		textAlign: 'center'
	},
	ctInputText: {
		fontSize: 13 * scale,
	},
	ctInputTextRed: {
		color: style.color.lightRed
	},
	money: {
		paddingLeft: 15 * scale
	},
	headBtnActive: {
		textAlign: 'right'
	},
	rowbt: {
		flexDirection: 'row',
		alignItems: 'center',
		justifyContent: 'space-between'
	},
	rowItem: { flex: 1 },
	ptop: { paddingTop: 15 * scale, marginBottom: 15 * scale },
	norl: {
		color: '#333',
		fontSize: 13 * scale,
		paddingBottom: 5 * scale
	},
	colorRed: {
		fontSize: 13 * scale,
		color: '#E02020'
	},
	themeColor: {
		color: style.color.themeColor,
		fontSize: 11 * scale
	},
	infoBox: {
		paddingTop: 15 * scale,
		paddingBottom: 10 * scale,
	},
	info: {
		fontSize: 11 * scale,
		paddingBottom: 10 * scale,
		lineHeight: 16 * scale
	}
})